package it.uniroma2.art.coda.projectionrule;

import java.util.ArrayList;
import java.util.List;

public class PlaceholderStruct {

	private String name; // the id for a particular type and feature
	private String type;
	private String typeAndFeat;
	private ProjectionRule prRule;
	private boolean isAlias; // true if it is an alias, false if it is a node (the field type has a value)
	private List<IfElseStruct> ifElseList;

	// placeholder taken from the nodes part of the projection rule
	public PlaceholderStruct(String name, String type, String typeAndFeat, ProjectionRule prRule) {
		initialize(name, type, typeAndFeat, prRule, false, null);
	}

	// placeholder taken from the nodes part of the projection rule that contains if/else
	public PlaceholderStruct(String name, String type, List<IfElseStruct> ifElseList, ProjectionRule prRule) {
		initialize(name, type, typeAndFeat, prRule, false, ifElseList);
	}

	// placeholder taken from the alias part of the projection rule
	public PlaceholderStruct(String name, String typeAndFeat, ProjectionRule prRule) {
		initialize(name, null, typeAndFeat, prRule, true, null);
	}

	private void initialize(String name, String type, String typeAndFeat, ProjectionRule prRule,
			boolean isAlias, List<IfElseStruct> ifElseList) {
		this.name = name;
		this.type = type;
		this.typeAndFeat = typeAndFeat;
		this.prRule = prRule;
		this.isAlias = isAlias;
		if (ifElseList == null)
			this.ifElseList = new ArrayList<IfElseStruct>();
		else
			this.ifElseList = ifElseList;
	}

	public String getName() {
		return name;
	}

	public String getType() {
		return type;
	}

	public String getTypeAndFeat() {
		return typeAndFeat;
	}

	public ProjectionRule getProjRule() {
		return prRule;
	}

	public boolean isAlias() {
		return isAlias;
	}

	public boolean hasIfElse() {
		if (ifElseList.size() > 0)
			return true;
		else
			return false;
	}

	public List<IfElseStruct> getIfElseList() {
		return ifElseList;
	}

}
